package com.my.util;

import org.joda.time.DateTime;
import org.joda.time.Days;

import java.util.Date;

/**
 * Created by wt on 2017/10/16.
 */
public class DateUtil {
    public static String Date2Str(Date date) {
        if (date == null) {
            return null;
        }

        return new DateTime(date).toString("yyyy-MM-dd HH:mm:ss");
    }

    public static Integer daysBetween(Date start, Date end) {
        DateTime dateTime_start = new DateTime(start);
        DateTime dateTime_end = new DateTime(end);
        return Days.daysBetween(dateTime_start, dateTime_end).getDays();
    }

    public static void main(String[] args) {
        Integer integer = DateUtil.daysBetween(null, null);
        System.out.println(integer);
    }


}